//
//  This copyrighted © code is written for and is part of the book
//  Smartphone-Based Real-Time Digital Signal Processing
//
package com.dsp.spectrogram;

public class Spectrogram {
	
	long pointer;
	
	public Spectrogram(){
		pointer = initialize(Settings.stepSize, Settings.windowSize, Settings.windowFunction, Settings.fftPoints);
	}
	
	public void release(){
		finish(pointer);
	}
	
	public void process(short[] in){
		compute(pointer, in);
	}
	
	public float getTime(){
		return getTime(pointer);
	}
	
	public float[] getDebug(int debugSelection){
		return getDebug(pointer, debugSelection);
	}

	//JNI Method Calls	
	private static native void compute(long memoryPointer, short[] in);
	private static native long initialize(int stepSize, int windowSize, int window, int fftPoints);
	private static native void finish(long memoryPointer);
	private static native float[] getDebug(long memoryPointer, int debugOutput);
	private static native float getTime(long memoryPointer);
    
    static {
		System.loadLibrary("nativeSpectrogram");
	}
	
}
